<template>
  <div>
    <header-page></header-page>
    <navbar> </navbar>
    <div class="loginwrap">
      <div class="reginsterbox">
        <form action="" class="formbox">
          <h1>注册沙发网</h1>
          <p>
            <input type="text" placeholder="用户名" id="user" />
          </p>
          <p>
            <input type="text" placeholder="邮箱" id="email" />
          </p>
          <p>
            <input type="text" placeholder="密码" id="psd" />
          </p>
          <p>
            <input type="text" placeholder="确认密码" />
          </p>
          <button class="rebtn" @click="chenge()">注册</button>
          <button class="lobtn">去登录</button>
        </form>
      </div>
    </div>
    <myfooter></myfooter>
  </div>
</template>

<script>
import headerPage from "./headerPage.vue";
import navbar from "./navbar.vue";
import myfooter from "./footerpage.vue";
export default {
  components: {
    headerPage,
    navbar,
    myfooter,
  },
  methods: {
    chenge() {
      var userName = $("#user").val();
      if (userName == "") {
        alert("用户名不能为空");
        return;
      }
      if (userName != "") {
        //   console.log(1);
        localStorage.setItem(
          "user",
          JSON.stringify({
            time: new Date(),
            userName,
          })
        );
        console.log(this);
        this.$router.push("/");
      }
    },
  },
};
</script>

<style >
* {
  margin: 0;
  padding: 0;
}
.loginwrap {
  width: 1200px;
  padding: 10px;
  margin: 10px auto 20px auto;
}
.loginwrap .reginsterbox {
  width: 650px;
  height: 380px;
  margin: 0 auto;
  background: #f5f5f5;
}
.loginwrap .reginsterbox .formbox {
  width: 650px;
  text-align: left;
  padding: 15px;
}
.formbox p input {
  width: 100%;
  height: 46px;
  border: #ccc 1px solid;
  padding-left: 10px;
}
.rebtn {
  width: 50%;
  background: #428bca;
  outline: none;
  border: none;
  height: 34px;
  color: #fff;
}
.lobtn {
  width: 100px;
  float: right;
  background: #fff;
  outline: none;
  border: 1px solid #ccc;
  height: 30px;
}
</style>